﻿using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Windows.Controls;
namespace LightSwitchApplication
{
    public partial class AlignmentsPublic
    {
        partial void CollectionDetailsSelected_Execute()
        {
            if (this.Collection.SelectedItem != null)
            {
                this.OpenModalWindow("ModalWindow");
                this.FindControl("ModalWindow").ControlAvailable += new EventHandler<ControlAvailableEventArgs>(ModalWindow_ControlAvailable);
                this.FindControl("PublicInfo").IsVisible = this.Collection.SelectedItem.HasPublicInformation;
            }
        }

        void ModalWindow_ControlAvailable(object sender, ControlAvailableEventArgs e)
        {
            ChildWindow window = (ChildWindow)e.Control;
            window.Closed += new EventHandler(window_Closed);
        }

        void window_Closed(object sender, EventArgs e)
        {
            ChildWindow window = (ChildWindow)sender;
            if (!(window.DialogResult.HasValue && window.DialogResult.Value))
            {
                window.Closed -= window_Closed;
            }
        }

        partial void SubmitModalWindow_Execute()
        {
            this.CloseModalWindow("ModalWindow");
        }
    }
}
